package com.tengju.data.infrastructure.repository.data.subject.convert;

import com.tengju.data.domain.model.clickhouse.BrandId;
import com.tengju.data.domain.model.clickhouse.subject.*;
import com.tengju.data.domain.shared.Month;
import com.tengju.data.infrastructure.persistence.mybatis.dataobject.SubjectSkuStatisticsDO;
import com.tengju.data.infrastructure.persistence.mybatis.dataobject.SubjectStatisticsDO;

/**
 * @author chenhang
 * @Date 2021/4/22
 */
public class SubjectSettleConvert {

    public static SubjectStatistics toStatistics(SubjectStatisticsDO subjectStatisticsDO) {
        if (subjectStatisticsDO == null) {
            return null;
        }
        return new SubjectStatistics(
                new SubjectId(subjectStatisticsDO.getSubjectId()),
                subjectStatisticsDO.getSubjectName(),
                subjectStatisticsDO.getMoneyOut(),
                subjectStatisticsDO.getBonus(),
                BonusSettleStatus.parse(subjectStatisticsDO.getStatus()),
                new Month(subjectStatisticsDO.getMonth())
        );
    }

    public static SubjectSkuStatistics toSkuStatistics(SubjectSkuStatisticsDO subjectSkuStatisticsDO) {
        if (subjectSkuStatisticsDO == null) {
            return null;
        }
        return new SubjectSkuStatistics(
                new SubjectId(subjectSkuStatisticsDO.getSubjectId()),
                subjectSkuStatisticsDO.getSubjectName(),
                new SkuId(subjectSkuStatisticsDO.getSkuId()),
                subjectSkuStatisticsDO.getSkuName(),
                new BrandId(subjectSkuStatisticsDO.getBrandId()),
                subjectSkuStatisticsDO.getBrandName(),
                subjectSkuStatisticsDO.getMoneyOut(),
                subjectSkuStatisticsDO.getBonus(),
                BonusSettleStatus.parse(subjectSkuStatisticsDO.getStatus()),
                new Month(subjectSkuStatisticsDO.getMonth())
        );
    }
}
